// pages/home/home.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // 页面路径
    sclist:'/pages/sclist/sclist',    //景点列表
    hotel_list:'/pages/hotel_list/index',  //酒店列表
    service:'/pages/service/index',    //微服务
    weivideo:'/pages/weivideo/index',  //微视频
    gotourl:'', //跳转index
    background:'',//top背景图
    http:'https://travel.gxucreate.com/',
    //天气信息
    weatherShanglin:"",
    weatherQing:"",
    weatherWendu:"",
    //景区分类列表
    scenicList:[{
      img:"/image/scenic-spot.png",
      name:"热门景点"
    },{
      img:"/image/map.png",
      name:"精品路线"
    },{
      img:"/image/hotel.png",
      name:"酒店住宿"
    },{
      img:"/image/guest-room.png",
      name:"特色民宿"
    },{
      img:"/image/shopping.png",
      name:"地标特产"
    },],
    headerList_1:[{
      img:"/image/guest-room.png",title:'上林概况',font:'让您更了解上林'
    },{
      img:"/image/hotel.png",title:'微视频',font:'轻松玩转景点'
    },{
      img:"/image/map.png",title:'最美上林',font:'精美图集'
    },{
      img:"/image/shopping.png",title:'智能服务',font:'轻松去旅游'
    },],
    headerList_2:[{
      img:'/image/map.png',name:'游记攻略'
    },{
      img:'/image/guest-room.png',name:'休闲娱乐'
    },{
      img:'/image/scenic-spot.png',name:'活动盛世'
    },{
      img:'/image/hotel.png',name:'旅游咨询'
    },],
    radioTxt:"",//广播
    //热门景点
    hotSpotsList:[{
      icon:'',name:''
    },{
      icon:'',name:''
    },{
      icon:'',name:''
    },],
    //当地特产
    dbtc:[],
    //特色美食
    tsms:[],
    //民俗文化
    cultureList:[{
      imglogo:'',title:''
    },{
      imglogo:'',title:''
    },{
      imglogo:'',title:''
    },],
    //旅游攻略
    travelList:[],
    //活动盛世
    activityList:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */

   //跳转事件
  goto:function(options){
    // console.log(options);
    let index = options.currentTarget.dataset.index //获取 home列表一的 index
    if(index == 0){
      return
    }else if(index == 1){
      this.setData({'gotourl':this.data.weivideo})

    }else if(index == 2){
      return
    }else if(index == 3){
      this.setData({'gotourl':this.data.service})
    }
    wx.navigateTo({
      url: this.data.gotourl,
    })
  },
  home: async function(){
    const home = await app.wxPost({
      url: '/mini/index.do',
    })
    //定义变量 便于设置
    const data = home.data
    // console.log(data);
     //top背景图
    this.setData({'background':data.setting.appLogo})   
    const weather = data.weather.results[0]
    this.setData({'weatherShanglin':weather.location.name,'weatherQing':weather.now.text,'weatherWendu':weather.now.temperature+'℃','hotSpotsList':data.hwlzlist,'dbtc':data.dbtc,'tsms':data.tsms.slice(0,2),'cultureList':data.minsu,'travelList':data.youji,'activityList':data.zhuanti,'radioTxt':data.zixuns[0].title}) //天气-地点
    // this.setData({'weatherQing':weather.now.text})  //天气-晴
    // this.setData({'weatherWendu':weather.now.temperature+'℃'}) //天气-温度
    // //热门景点
    // this.setData({'hotSpotsList':data.hwlzlist})
    // //当地特产
    // this.setData({'dbtc':data.dbtc})
    // //特色美食
    // this.setData({'tsms':data.tsms.slice(0,2)}) //截取数组内前两个元素
    // //民俗文化
    // this.setData({'cultureList':data.minsu})
    // //旅游攻略
    // this.setData({'travelList':data.youji})
    // //活动盛世
    // this.setData({'activityList':data.zhuanti})
    // //广播
    // this.setData({'radioTxt':data.zixuns[0].title})

  },

  onLoad: function (options) {
    this.home()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    // console.log('下拉')
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    console.log('上拉');
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})